using System;
using System.Collections.Generic;
namespace AppToolKit.Core.Context.Spring.AutoConstruction
{
	public class BusinessManager : IBusinessManager
	{
		public List<IRemoteBusinessBuilder> Builderes
		{
			get;
			set;
		}
		public void RegisterBusiness(Type type)
		{
			foreach (IRemoteBusinessBuilder current in this.Builderes)
			{
				if (current.IsSupport(type))
				{
					current.Register(type);
					current.Export(type);
					return;
				}
			}
			throw new ContextManageException("没找到可用的服务注册器");
		}
		public object GetBusiness(Type type)
		{
			object result;
			foreach (IBusinessBuilder current in this.Builderes)
			{
				if (current.IsSupport(type))
				{
					result = current.GetObject(type);
					return result;
				}
			}
			result = null;
			return result;
		}
	}
}
